const app = getApp();
import Paging from '../../../../wxjs/Paging.js'
var pag = new Paging();

var data = {
  xhx_images: app.xhx_images,
  xhx_route: app.xhx_route,
  curNav:0,
  uuid:null,
  totalPrice:null,
};

var currentPage = {
  data,
  listParams: {},
  reqUrl: app.serAddrs.getUsedCoupon,
  
  // navToNext,
  navTap,
  onLoad,
  navToNext,
};

var page = Object.assign(pag.func() , currentPage);

Page(page);

function onLoad(options) {
  console.log(options)
  const that = this;
  that.setData({
    uuid: options.uuid,
    totalPrice: options.totalPrice,
  })
  // 初始化上拉加载方法
  that.navTap();
}

function navToNext(event){
  console.log(event)
  let pages = getCurrentPages();//当前页面
  let prevPage = pages[pages.length - 2];//上一页面
  console.log(event.target.dataset)
  prevPage.setData({//直接给上移页面赋值
    amount: event.target.dataset.amount,
    couponId: event.target.dataset.couponId
  });
  prevPage.getTotalPrice();
  wx.navigateBack({//返回
    delta: 1
  })
}

function navTap(event) {
  const that = this;
  if(event){
    that.setData({
      curNav: event.target.dataset.id
    })
  }
  
  that.listParams.couponUserId = app.userInfo.userId || 466;
  that.listParams.status = Number(that.data.curNav || 0);
  that.listParams.lectureUuid = that.data.uuid;
  that.listParams.orderAmount = that.data.totalPrice; 
  console.log(that.listParams)
  that.pageListInit();
}